<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
	<script src="<?php echo base_url()?>themes/default/js/jquery.area.js"></script>
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>

		<ul class="breadcrumb">
			<li>
				<i class="icon-home home-icon"></i>
				<a href="#">系统首页</a>
			</li>
			<li class="active">
				基础数据管理
			</li>
            <li>
				<a href="#">支付方式</a>
			</li>
            <li class="active">
				编辑
			</li>
		</ul><!-- .breadcrumb -->
	</div>
	<div class="page-content">
        
        <div class="page-header">
			<h1>编辑支付接口</h1>
		</div>
		<div class="row">
			 <div class="col-xs-12">
				<!-- PAGE CONTENT BEGINS -->

					<form id="usrform" action="<?php echo base_url()."admin/basis_data/edit_payment"?>" method="post">
				    	<div class="box-body" style="display: inline-block;width: 100%">
				    		<?php if(!empty($payment) && count($payment)>0){
				    				foreach($payment as $val){
				    		?>
				    		<input name="id" style="display: none;" value="<?php echo $val->id?>"/>
				    		<table id="sample-table-1" class="table table-striped table-bordered table-hover">
                                    	    <tr><td colspan="6" style="text-align: center;"><b>编辑支付接口</b></td></tr>
											<tr>
                                            	<td><b>支付接口名称：</b></td>
                                                <td><b><?php echo $val->name?></b></td>
                                                <td><b>类名:</b></td>
                                                <td><b><?php echo $val->class_name?></b></td>
                                                <td rowspan="3"><b>上传Logo:</b></td>
                                                <td rowspan="3"><b>
                                                	<div id="select">
							  							<input type="hidden" id="url" name="up_url" value="<?php echo $val->logo?>">
							    						<img id="headpic" src="<?php echo $val->logo?>" width="200" height="50">
													</div>
													<div><a class="btn_style" onClick='del_img()' >删除logo</a></div>
												</b></td>
                                            </tr>
                                            <tr>
                                            	<td><b>状态：</b></td>
                                                <td><b>
                                                	<label style="margin-left: 15px;">
					                        			<input type="radio" name="status" value="0" <?php if($val->status == 0){ echo "checked"; }?>>
					                        			<span class="lbl">启用</span>
					                        		</label>
					                        		<label style="margin-left: 15px;">
					                        			<input type="radio" name="status" value="1" <?php if($val->status == 1){ echo "checked"; }?>>
					                        			<span class="lbl">禁用</span>
					                        		</label>
                                                </b></td>
                                                <td rowspan="2"><b>类型:</b></td>
                                                <td rowspan="2"><b>
                                                	<label style="margin-left: 15px;">
					                        			<input type="radio" name="type" value="1" <?php if($val->type == 1){ echo "checked"; }?>>
					                        			<span class="lbl">线上</span>
					                        		</label>
					                        		<label style="margin-left: 15px;">
					                        			<input type="radio" name="type" value="2" <?php if($val->type == 2){ echo "checked"; }?>>
					                        			<span class="lbl">线下</span>
					                        		</label>
                                                </b></td>
                                            </tr>
                                            <tr>
                                            	<td>
                                            		<b>客户端类别:</b>
                                            	</td>
                                            	<td>
                                            	<b>
                                            		<label style="margin-left: 15px;">
					                        			<input type="radio" name="client_type" value="1" <?php if($val->client_type == 1){ echo "checked"; }?>>
					                        			<span class="lbl">PC端</span>
					                        		</label>
					                        		<label style="margin-left: 15px;">
					                        			<input type="radio" name="client_type" value="2" <?php if($val->client_type == 2){ echo "checked"; }?>>
					                        			<span class="lbl">微信端</span>
					                        		</label>
					                        		<label style="margin-left: 15px;">
					                        			<input type="radio" name="client_type" value="3" <?php if($val->client_type == 3){ echo "checked"; }?>>
					                        			<span class="lbl">APP端</span>
					                        		</label>
					                        		<label style="margin-left: 15px;">
					                        			<input type="radio" name="client_type" value="0" <?php if($val->client_type == 0){ echo "checked"; }?>>
					                        			<span class="lbl">全部</span>
					                        		</label>
                                            	</b>
                                            	</td>
                                            </tr>
                           </table>
				            <div class="form-group col-xs-12">
					            <label><b>排序:</b></label><span style="color: #a94442;"><?php echo form_error("city_name")?></span>
					            <input name="sortnum" type="text" class="form-control" placeholder="输入 ..." value="<?php echo $val->sortnum?>" check-type="required">
				            </div>
				            <div class="form-group col-xs-12">
					            <label><b>描述:</b></label>
					            <input name="desc" type="text" class="form-control" placeholder="输入 ..." value="<?php echo $val->desc?>">
				            </div>
				            <?php
				            if(!empty($val->config)){
				            	foreach($val->config as $key=>$val){
				            ?>
					            <div class="form-group col-xs-12">
						            <label><b><?php echo $val[0] ?>:</b></label><span style="color: #a94442;"><?php echo form_error("city_name")?></span>
						            <input name="val[]" type="text" class="form-control" placeholder="输入 ..." value="<?php echo $val[1];?>" check-type="required">
						            <input name="key[]" style="display: none;" value="<?php echo $key?>">
						            <input name="config[]" style="display: none;" value="<?php echo $val[0]?>">
					            </div>
				            <?php 
									}
								}
				            		}
				            	}
				            ?>
			            </div>
			            <div class="clearfix form-actions">
							<div class="col-md-offset-3 col-md-9">
								<button id="btnSubmit" class="btn btn-info" type="submit">
									<i class="icon-ok bigger-110"></i>
									保存
								</button>
	
								&nbsp; &nbsp; &nbsp;
								<a class="btn" href="<?php echo base_url()."admin/basis_data/payment"?>">
									<i class="icon-undo bigger-110"></i>
									返回
								</a>
							</div>
						</div>
					</form>
			</div>
		</div><!-- /.row -->
	</div><!-- /.page-content -->
</div><!-- /.main-content -->
	<script type="text/javascript">
	$("#usrform").validation();
	//保存
	$("#btnSubmit").on('click',function(event){
	  // 2.最后要调用 valid()方法。
	  if ($("#usrform").valid()==false){
	    return false;
	  }
	});
	</script>
	<script>
	function del_img(){
		$('#headpic').attr('src','');
        $('#url').val('');
	}
    $(function () {
        var uploader = null;
        //上传初始化
		if(uploader==null){
        	uploader = WebUploader.create({
        	    // 选完文件后，是否自动上传。
        	    auto: true,
        	    //不压缩图像
        	    compress:false,
        	    // swf文件路径
        	    swf:'<?php echo base_url()?>themes/webuploader/Uploader.swf',
        	    // 文件接收服务端。
        	    server: '<?php echo site_url("admin/upyun/webuploader")?>',
        	    // 选择文件的按钮。可选。
        	    // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        	    pick: '#select',
        	    // 只允许选择图片文件。
        	    accept: {
        	        title: 'Images',
        	        extensions: 'gif,jpg,jpeg,bmp,png',
        	        mimeTypes: 'image/*'
        	    }
        	});
        	//文件上传成功，显示图片。
        	uploader.on('uploadSuccess', function(file,response) {
        		$('#headpic').attr('src',response.file_path);
        		uploader.reset();
        		$('#url').val(response.file_path);
        	});

        	// 文件上传失败，显示上传出错。
        	uploader.on( 'uploadError', function( file ) {
        		$('#error').html('上传失败');
        		$('#error').show();
        	});
		}
    });
    </script>